package com.me.rabbitMQ.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;


public class ConnectionUtil {

    public static Connection getConnect() throws Exception {
        //定义连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        //设置服务地址
        factory.setHost("localhost");
        //端口
        factory.setPort(5672);
        //设置账户信息：vhost，用户名，密码
        factory.setVirtualHost("/testmq");
        factory.setUsername("testmq");
        factory.setPassword("testmq");
        //通过工程获得连接
        Connection connection = factory.newConnection();
        return connection;
    }
}
